<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>

<script type="text/javascript">
	var expensegrid;
	$(function() {

		expensegrid = $('#expensegrid')
				.datagrid(
						{
							//title : '商品列表',
							url : '${ctx}/autoinn/expense/list',
							striped : true,
							rownumbers : true,
							pagination : true,
							singleSelect : true,
							idField : 'id',
							sortName : 'innertime',
							sortOrder : 'desc',
							pageSize : 50,
							pageList : [ 10, 20, 30, 40, 50, 100, 200, 300,
									400, 500 ],
							frozenColumns : [ [ {
								width : '100',
								title : '会员昵称',
								field : 'nickname'
								
							} ] ],
							columns : [ [
									{
										width : '80',
										title : '会员等级',
										field : 'level',
										formatter : function(value, row) {
											  switch(value){
											  case 0:
												return sy.formatString("<span align='center'>普通会员</span>");
												break;
											  case 1:
												 
												  return sy.formatString("<span align='center'>青铜会员</span>");
												  break;
											  case 2:
												  return sy.formatString("<span align='center'>青白银会员</span>");
												  break;
											  case 3:
												  return sy.formatString("<span align='center'>黄金会员</span>");
												  break;
											  case 4:
												  return sy.formatString("<span align='center'>白金会员</span>");
												  break;
											  case 5:
												  return sy.formatString("<span align='center'>钻石会员</span>");
												  break;
											   default:
													  break;
											  }
												  
											
										}
									},
									{
										width : '100',
										title : '门店',
										field : 'name'
									},
									{
										width : '100',
										title : '商品名称',
										field : 'proname'
									},
									{
										width : '100',
										title : '分类名称',
										field : 'pathname'
									},
									{
										width : '60',
										title : '消费金额',
										field : 'price'
									},
									{
										width : '60',
										title : '折扣',
										field : 'zhekou',
										
									},
									{
										width : '60',
										title : '应付金额',
										field : 'yfprice'
									},
									{
										width : '150',
										title : '描述',
										field : 'des'
									},
									{
										width : '120',
										title : '消费时间',
										field : 'innertime',
										sortable : true
									},
									{
										width : '90',
										title : '操作',
										field : 'action',
										formatter : function(value, row) {
											var str = "";
											<shiro:hasPermission name="/autoinn/expense/delete">
											str += sy
											.formatString(
													'<span onclick="expenseremoveFun(\'{0}\');" style="margin-left:3px;cursor:pointer;">【{1}】</span>',
													row.id, "删除");
											</shiro:hasPermission>
											return str;
										}
									}
									 ] ],
							toolbar : '#expensetoolbar',
							onBeforeLoad : function(param) {
								parent.$.messager.progress({
									text : '数据加载中....'
								});
							},
							onLoadSuccess : function(data) {
								$('.iconImg').attr('src', sy.pixel_0);
							
								parent.$.messager.progress('close');
							}
							
							
						});
	});

	

	//删除
	var expenseremoveFun = function(id) {
		parent.$.messager.confirm('询问', '您确定要删除此记录？', function(r) {
			if (r) {
				$.post('${ctx}/autoinn/expense/delete/' + id, {
					id : id
				}, function(data) {
					expensegrid.datagrid('reload');
				}, 'json');
			}
		});
	};
	
	var expensexportXls=function(){
		window.location.href ="${ctx}/autoinn/expense/exportXls";
	}

	
</script>
<!-- 界面布局  -->
<div class="easyui-layout" style="width: 100%; height: 100%;"
	data-options="fit:true,border:false">

	<div id="expensetoolbar" style="display: none;">
		<table>
			<tr>
				<td>
					<form id="expensesearchForm">
						<table>
							<tr style="font-size: 13px;">
								<td>会员昵称</td>
								<td><input name="nickname" style="width: 80px;" /></td>
								<td>门店名称</td>
								<td><input type="text" name="storename" style="width:80px"/></td>
								<td>电话号码</td>
								<td><input name="phoneNum" style="width:80px;"/></td>
								<td>创建时间</td>
								<td><input name="starinnertime" class="Wdate"
									onclick="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})"
									readonly="readonly" style="width: 120px;" />-<input
									name="endinnertime" class="Wdate"
									onclick="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})"
									readonly="readonly" style="width: 120px;" /></td>
								
								<td><a href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-search',plain:true"
									onclick="expensegrid.datagrid('load',sy.serializeObject($('#expensesearchForm')));">过滤</a><a
									href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-reload',plain:true"
									onclick="$('#expensesearchForm input').val('');expensegrid.datagrid('load',{});">重置过滤</a>
									<a href="javascript:expensexportXls();" class="easyui-linkbutton"
								data-options="iconCls:'icon-redo',plain:true" onclick="">导出</a>
									</td>
							</tr>
						</table>
					</form>
				</td>
			</tr>
		</table>
	</div>
	<div data-options="region:'center',title:'消费管理'" style="padding: 2px;">
		<div class="easyui-layout" data-options="fit : true,border : false">
			<div data-options="region:'center',border:false">
				<table id="expensegrid" data-options="fit:true,border:false"></table>
			</div>
		</div>
	</div>
</div>